﻿using System.IO;
using System.Collections.Generic;

namespace Game.Lib.CSG
{
    public abstract class Shape : Serializable
    {
        public abstract List<Vector> CriticalPoints { get; }
        public abstract void Serialize(Stream s);

        public abstract void Deserialize(Stream s);

        public virtual byte[] ToBytes()
        {
            MemoryStream ms = new MemoryStream();
            Deserialize(ms);
            return ms.ToArray();
        }

        public virtual void FromBytes(byte[] data, int pos)
        {
            MemoryStream ms = new MemoryStream(data);
            ms.Position = pos;
            Deserialize(ms);
        }
    }
}
